package com.small.act;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.Toast;

import com.small.R;
import com.small.view.custview.w8.MyImageView;

public class SearchAdapter extends BaseAdapter {
	private Context mContext;
	LayoutInflater li;

	public SearchAdapter(Context context) {
		this.mContext= context; 
		this.li = LayoutInflater.from(context);
		mContext = context;
	}

	public int getCount() {
		return 6;
	}

	public Object getItem(int arg0) {
		return null;
	}

	public long getItemId(int arg0) {
		return 0;
	}

	public View getView(int position, View convertView, ViewGroup parent) { 

		ViewHolder holder = null;
		if (null == convertView) {
			holder = new ViewHolder();
			convertView = li.inflate( R.layout.activity_searchdiscount_list_item, null); 
			// convertView.findViewById(R.id.tv_distance);
			holder.img_title = (MyImageView) convertView .findViewById(R.id.img_title);
			holder.img_title.setScaleType(ImageView.ScaleType.CENTER_CROP);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		if (position % 2 == 1) {
			holder.img_title.setImageResource(R.drawable.search_tag_green);
		} else {
			holder.img_title.setImageResource(R.drawable.search_tag_orange);
		}
		holder.img_title.SetAnimationOnOff(true);
		final String s = ""+position;
		holder.img_title.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Toast.makeText(mContext, ""+s, Toast.LENGTH_SHORT).show(); 
				
			}
		});
		return convertView;
	}

	private class ViewHolder {
		// public TextView tv_title;
		// public TextView tv_content;
		// public TextView tv_disctance;
		public MyImageView img_title;
	}
}
